<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>不同性别用户浏览支付页面转化率</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js"></script>
    <style>
        .chart-container {
            max-width: 800px;
            margin: 2rem auto;
            padding: 1.5rem;
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body class="bg-gray-50">
<div class="chart-container">
    <h2 class="text-xl font-bold mb-4">不同性别用户浏览支付页面转化率</h2>
    <div class="h-80">
        <canvas id="genderConversionChart"></canvas>
    </div>
</div>

<script>
    // 准确的性别转化率数据
    const genderData = [
        { gender: "未知", conversion_rate: 0.12596401028277635 },
        { gender: "女性", conversion_rate: 0.15112994350282485 },
        { gender: "男性", conversion_rate: 0.11775352675006655 }
    ];

    document.addEventListener("DOMContentLoaded", () => {
        new Chart(document.getElementById("genderConversionChart"), {
            type: "bar",
            data: {
                labels: genderData.map(g => g.gender),
                datasets: [{
                    label: "转化率 (%)",
                    data: genderData.map(g => (g.conversion_rate * 100).toFixed(2)),
                    backgroundColor: ["#6B7280", "#EC4899", "#3B82F6"],
                    borderRadius: 4,
                    barPercentage: 0.6
                }]
            },
            options: {
                responsive: true,
                scales: {
                    y: {
                        beginAtZero: true,
                        max: 16,
                        ticks: { callback: v => v + "%" },
                        title: {
                            display: true,
                            text: "转化率"
                        }
                    }
                },
                plugins: {
                    tooltip: {
                        callbacks: {
                            label: l => `${l.dataset.label}: ${l.raw}%`
                        }
                    }
                },
                animation: {
                    duration: 1500
                }
            }
        });
    });
</script>
</body>
</html>